﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using SwitchHostProject.Model;

namespace SwitchHostProject.Service.DTSelector
{
    class HostGroupDataTemplateSelector : DataTemplateSelector
    {
        public override DataTemplate SelectTemplate(object item, DependencyObject container)
        {
            FrameworkElement element = container as FrameworkElement;

            if (element != null && item != null && item is HostGroup)
            {
                HostGroup hg = item as HostGroup;

                if (hg.Type == "0")
                    return element.FindResource("hostGroupTemplate") as DataTemplate;
                else
                    return element.FindResource("hostItemTemplate") as DataTemplate;
            }

            return null;
        }
    }
}
